BatchManager   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 6

4 Functions

Rating   Name   Duplication   Size   Complexity  
A getUsableDataset 0 3 2
A getBoost 0 3 2
A insertBatch 0 3 1
A getBatch 0 3 1
1
import { CodeBoost } from '@/lib/CodeBoost';
2
3
export class BatchManager {
4
    public data: any[] = [];
5
6
    constructor(public filename: string, public codeboost: CodeBoost) {
7
        this.data = filename ? require(filename) : [];
8
    }
9
10
    protected getBoost(boostName: string) {
11
        return this.codeboost.getBoost(boostName);
12
    }
13
14
    public getBatch(boostName: string, size: number) {
15
        return this.getUsableDataset(boostName).slice(0, size);
16
    }
17
18
    public insertBatch(item: any) {
19
        this.data.push({ name: item });
20
    }
21
22
    public getUsableDataset(boostName: string) {
23
        return this.data.filter(repo => this.getBoost(boostName)?.canRunOnRepository(repo.name));
24
    }
25
}
26